<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../base.jsp"%>
<!DOCTYPE html>
<html>

<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>黑马面面管理系统</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <style>
        label{
            width:auto;
            margin:6px 4px 6px 4px;
            float: left;
        }
        .form-control{
            width: auto;
            margin:3px 20px 3px 0px;
            float: left;
        }
        /*.searchDivT{*/
        /*    width: 25%;*/
        /*    float: left;*/
        /*}*/
        /*.searchDivS{*/
        /*    width: 20%;*/
        /*    float: left;*/
        /*}*/
    </style>
</head>
<script>
    function deleteById() {
        var id = getCheckId()
        if(id) {
            if(confirm("你确认要删除此条记录吗？")) {
                location.href="${ctx}/system/user?operation=delete&id="+id;
            }
        }else{
            alert("请勾选待处理的记录，且每次只能勾选一个")
        }
    }

    function roleList() {
        var id = getCheckId()
        if(id) {
            location.href="${ctx}/system/user?operation=userRoleList&userId="+id;
        }else{
            alert("请勾选待处理的记录，且每次只能勾选一个")
        }
    }
</script>
<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
<section class="content-header">
    <h1>
        系统管理
        <small>用户管理</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="all-admin-index.html"><i class="fa fa-dashboard"></i> 首页</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-primary">
        <div class="box-header with-border">
            <h3 class="box-title">用户列表</h3>
        </div>
        <div class="box-body">
            <div class="table-box">
                <form action="${ctx}/system/user?operation=conditionSearch" method="post" autocomplete="off">
                    <div class="searchDivT">
                        <label for="searchUserName">姓名</label>
                        <input type="text" value="${searchUserName}"
                               id="searchUserName" name="searchUserName" class="form-control input-sm"placeholder="请输入用户名关键字">
                    </div>
                    <div class="searchDivS">
                    <label for="searchGender">性别</label>
                        <select id="searchGender" name="searchGender" class="form-control input-sm">
                            <option ${searchGender == 100 ?'selected':''} value="">请选择</option>
                            <option ${searchGender == "0" ?'selected':''} value="0">&nbsp;&nbsp;&nbsp;男&nbsp;&nbsp;&nbsp;</option>
                            <option ${searchGender == "1" ?'selected':''} value="1">&nbsp;&nbsp;&nbsp;女&nbsp;&nbsp;&nbsp;</option>
                        </select>
                    </div>
                    <div class="searchDivS">
                        <label for="searchDept">部门</label>
                            <select id="searchDept" class="form-control input-sm" onchange="document.getElementById('deptName').value=this.options[this.selectedIndex].text" name="searchDept">
                                <option value="">请选择</option>
                                <c:forEach items="${deptList}" var="item">
                                    <option ${searchDept == item.id ?'selected':''} value="${item.id}">${item.deptName}</option>
                                </c:forEach>
                            </select>
                    </div>
                    <div class="searchDivS">
                        <label for="searchState">状态</label>
                        <select id="searchState" name="searchState" class="form-control input-sm">
                            <option ${searchState == 100 ?'selected':''} value="">请选择</option>
                            <option ${searchState == "0" ?'selected':''} value="0">&nbsp;&nbsp;停用&nbsp;&nbsp;</option>
                            <option ${searchState == "1" ?'selected':''} value="1">&nbsp;&nbsp;启用&nbsp;&nbsp;</option>
                        </select>
                    </div>
                    <div class="searchDivT">
                        <label for="searchEmail">邮箱</label>
                        <input type="text" value="${searchEmail}"
                               id="searchEmail" name="searchEmail" class="form-control input-sm"placeholder="请输入关键字">
                    </div>
                    <div class="searchDivB">
                         <button type="submit">查询</button>
                    </div>
                </form>
                <div class="pull-left" style="clear:both">
                    <div class="form-group form-inline">
                        <div class="btn-group">
                            <button type="button" class="btn btn-default" title="新建" onclick='location.href="${ctx}/system/user?operation=toAdd"'><i class="fa fa-file-o"></i> 新建</button>
                            <button type="button" class="btn btn-default" title="删除" onclick='deleteById()'><i class="fa fa-trash-o"></i> 删除</button>
                            <button type="button" class="btn btn-default" title="刷新" onclick="window.location.reload();"><i class="fa fa-refresh"></i> 刷新</button>
                            <button type="button" class="btn btn-default" title="角色" onclick="roleList()"><i class="fa fa-user-circle-o"></i> 角色</button>
                        </div>
                    </div>
                </div>
                <div class="box-tools pull-right">
                    <div class="has-feedback">
                    </div>
                </div>
                <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                    <thead>
                    <tr>
                        <th class="" style="padding-right:0px;"></th>
                        <th class="sorting">邮箱</th>
                        <th class="sorting">用户名</th>
                        <th class="sorting">性别</th>
                        <th class="sorting">所属部门</th>
                        <th class="sorting">状态</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <c:forEach items="${page.list}" var="item" varStatus="status">
                    <tr>
                        <td><input name="id" value="${item.userId}" type="checkbox"></td>
                        <td>${item.email }</td>
                        <td>${item.userName}</td>
                        <td>${item.gender ==0?'男':'女'}</td>
                        <td>${item.dept.deptName }</td>
                        <td>${item.state  ==0?'停用':'启用'}</td>
                        <th class="text-center">
                            <button type="button" class="btn bg-olive btn-xs" onclick='location.href="${ctx}/system/user?operation=toEdit&id=${item.userId}"'>编辑</button>
                        </th>
                    </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="box-footer">
            <jsp:include page="../../common/page.jsp">
                <jsp:param value="${ctx}/system/user?operation=list" name="pageUrl"/>
            </jsp:include>
        </div>
    </div>

</section>
</div>
</body>
</html>